package com.ruoyi.pump.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pump.domain.TPumpPoint;
import com.ruoyi.pump.service.ITPumpPointService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 泵组节点Controller
 * 
 * @author ruoyi
 * @date 2025-09-18
 */
@RestController
@RequestMapping("/pump/pumppoint")
public class TPumpPointController extends BaseController
{
    @Autowired
    private ITPumpPointService tPumpPointService;

    /**
     * 查询泵组节点列表
     */
    @PreAuthorize("@ss.hasPermi('pump:pumppoint:list')")
    @GetMapping("/list")
    public TableDataInfo list(TPumpPoint tPumpPoint)
    {
        startPage();
        List<TPumpPoint> list = tPumpPointService.selectTPumpPointList(tPumpPoint);
        return getDataTable(list);
    }

    /**
     * 导出泵组节点列表
     */
    @PreAuthorize("@ss.hasPermi('pump:pumppoint:export')")
    @Log(title = "泵组节点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TPumpPoint tPumpPoint)
    {
        List<TPumpPoint> list = tPumpPointService.selectTPumpPointList(tPumpPoint);
        ExcelUtil<TPumpPoint> util = new ExcelUtil<TPumpPoint>(TPumpPoint.class);
        util.exportExcel(response, list, "泵组节点数据");
    }

    /**
     * 获取泵组节点详细信息
     */
    @PreAuthorize("@ss.hasPermi('pump:pumppoint:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tPumpPointService.selectTPumpPointById(id));
    }

    /**
     * 新增泵组节点
     */
    @PreAuthorize("@ss.hasPermi('pump:pumppoint:add')")
    @Log(title = "泵组节点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPumpPoint tPumpPoint)
    {
        return toAjax(tPumpPointService.insertTPumpPoint(tPumpPoint));
    }

    /**
     * 修改泵组节点
     */
    @PreAuthorize("@ss.hasPermi('pump:pumppoint:edit')")
    @Log(title = "泵组节点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPumpPoint tPumpPoint)
    {
        return toAjax(tPumpPointService.updateTPumpPoint(tPumpPoint));
    }

    /**
     * 删除泵组节点
     */
    @PreAuthorize("@ss.hasPermi('pump:pumppoint:remove')")
    @Log(title = "泵组节点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tPumpPointService.deleteTPumpPointByIds(ids));
    }
}
